home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / tos / futils / futils~1 / src / shell13s.zoo / shell1.3 / configure < prev    next >
Encoding:
Text File  |  1991-10-17  |  10.0 KB  |  384 lines

  1. :
  2. # Guess values for system-dependant variables and create `Makefile'.
  3. # Copyright (C) 1991 Free Software Foundation, Inc.
  4.  
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2, or (at your option)
  8. # any later version.
  9.  
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. # GNU General Public License for more details.
  14.  
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19. # Usage: configure [+srcdir=DIR] [+host=HOST] [+gas] [+nfp] [TARGET]
  20. # All args except +srcdir=DIR are ignored.
  21.  
  22. trap 'rm -f conftest conftest.c; exit 1' 1 3 15
  23.  
  24. set +u # Make sure unset variables are ok.
  25.  
  26. # Make sure we don't find the System V /etc/install.
  27. PATH=`echo $PATH|sed 's,^:,|,
  28. s,:$,|,
  29. s,:/usr/etc,,g
  30. s,/usr/etc:,,g
  31. s,:/etc,,g
  32. s,/etc:,,g
  33. s,|,:,g'`
  34.  
  35. # A filename unique to this package, relative to the directory that
  36. # configure is in, which we can look for to find out if srcdir is correct.
  37. unique_file=src/stty.c
  38.  
  39. for arg in $*; do
  40.   # Handle +srcdir with a space before the argument.
  41.   if [ x$next_srcdir = xyes ]; then srcdir=$arg; next_srcdir=
  42.   # Handle +host with a space before the argument.
  43.   elif [ x$next_host = xyes ]; then next_host=
  44.   else 
  45.     case $arg in
  46.      -srcdir=* | +srcdir=* | +srcdi=* | +srcd=* | +src=* | +sr=* | +s=*)
  47.     srcdir=`echo $arg | sed 's/[+-]s[a-z]*=//'` ;;
  48.      -srcdir | +srcdir | +srcdi | +srcd | +src | +sr | +s)
  49.     next_srcdir=yes ;;
  50.      -host=* | +host=* | +hos=* | +ho=* | +h=*) ;;
  51.      -host | +host | +hos | +ho | +h)
  52.     next_host=yes ;;
  53.      -gas | +gas | +ga | +g) ;;
  54.      -nfp | +nfp | +nf | +n) ;;
  55.      *) ;;
  56.     esac
  57.   fi
  58. done
  59.  
  60. # Find the source files, if location was not specified.
  61. if [ x$srcdir = x ]; then
  62.   srcdirdefaulted=yes; srcdir=.
  63.   if [ ! -r $unique_file ]; then srcdir=`pwd`/..; fi
  64. fi
  65. if [ $srcdir != . ]; then VPATH='VPATH = $(srcdir)'; fi
  66.  
  67. if [ ! -r $srcdir/$unique_file ]; then
  68.   if [ x$srcdirdefaulted = xyes ]; then
  69.     echo "$0: Can not find sources in \`.' or \`..'." 1>&2
  70.   else
  71.     echo "$0: Can not find sources in \`${srcdir}'." 1>&2
  72.   fi
  73.   exit 1
  74. fi
  75.  
  76. if test "$RANDOM" = "$RANDOM"; then
  77.   # Plain old Bourne shell.
  78.   echo checking for gcc
  79.   test -z "$CC" -a -n "`gcc 2>&1`" && CC="gcc -O"
  80.  
  81.   echo checking for install
  82.   if test -z "$INSTALL" -a -n "`install 2>&1`"; then
  83.     INSTALL="install -c"
  84.     INSTALLDATA="install -c -m644"
  85.   fi
  86.  
  87.   echo checking for ranlib
  88.   test -z "$RANLIB" -a -n "`ranlib conftest 2>&1`" && RANLIB=ranlib
  89.   rm -f conftest
  90. else
  91.   # ksh, bash or zsh.  ksh and zsh write "command not found" to stderr.
  92.   echo checking for gcc
  93.   test -z "$CC" && type gcc && CC="gcc -O"
  94.  
  95.   echo checking for install
  96.   if test -z "$INSTALL" && type install; then
  97.     INSTALL="install -c"
  98.     INSTALLDATA="install -c -m644"
  99.   fi
  100.  
  101.   echo checking for ranlib
  102.   test -z "$RANLIB" && type ranlib && RANLIB=ranlib
  103. fi
  104.  
  105. CC=${CC-cc}
  106. INSTALL=${INSTALL-cp}
  107. INSTALLDATA=${INSTALLDATA-cp}
  108. RANLIB=${RANLIB-echo}
  109.  
  110. INCLUDEDIR=${INCLUDEDIR-/usr/include}
  111.  
  112. rm -f conftest conftest.c
  113. compile="$CC $DEFS conftest.c -o conftest $LIBS >/dev/null 2>&1"
  114.  
  115. # Check whether various functions exist.
  116.  
  117. # Functions we provide replacements for.
  118. for func in mktime stime strftime strstr
  119. do
  120.   echo checking for $func
  121.   echo "main() { exit(0); ${func}(); }" > conftest.c
  122.   eval $compile
  123.   if test -s conftest && ./conftest 2>/dev/null; then :
  124.   else LIBOBJS="$LIBOBJS ${func}.o"
  125.   fi
  126.   rm -f conftest conftest.c
  127. done
  128.  
  129. # Functions whose absence we work around.
  130. for func in ftime vprintf
  131. do
  132.   echo checking for $func
  133.   echo "main() { exit(0); ${func}(); }" > conftest.c
  134.   eval $compile
  135.   if test -s conftest && ./conftest 2>/dev/null; then :
  136.   else DEFS="$DEFS -D`echo $func|tr '[a-z]' '[A-Z]'`_MISSING"
  137.   fi
  138.   rm -f conftest conftest.c
  139. done
  140.  
  141. case "$DEFS" in
  142. *VPRINTF_MISSING*)
  143.   func=_doprnt
  144.   echo checking for $func
  145.   echo "main() { exit(0); ${func}(); }" > conftest.c
  146.   eval $compile
  147.   if test -s conftest && ./conftest 2>/dev/null; then :
  148.   else DEFS="$DEFS -DDOPRNT_MISSING"
  149.   fi
  150.   rm -f conftest conftest.c
  151.   ;;
  152. esac
  153.  
  154. echo checking for setpriority
  155. echo '#include <sys/time.h>
  156. #include <sys/resource.h>
  157. main() { exit(0); setpriority(0, 0, 0); }' > conftest.c
  158. eval $compile
  159. if test -s conftest && ./conftest 2>/dev/null; then
  160.   PROGS="$PROGS nice nohup"
  161.   MAN="$MAN gnice.1 gnohup.1"
  162. else
  163.   rm -f conftest conftest.c
  164.   echo checking for nice
  165.   echo 'main() { exit(0); nice(); }' > conftest.c
  166.   eval $compile
  167.   if test -s conftest && ./conftest 2>/dev/null; then
  168.     DEFS="$DEFS -DNICE_PRIORITY"
  169.     PROGS="$PROGS nice nohup"
  170.     MAN="$MAN gnice.1 gnohup.1"
  171.   fi
  172. fi
  173. rm -f conftest conftest.c
  174.  
  175. # Check for various header files.
  176.  
  177. echo checking for sys/utsname.h
  178. if test -f $INCLUDEDIR/sys/utsname.h; then
  179.   PROGS="$PROGS uname"
  180.   MAN="$MAN guname.1"
  181. fi
  182.  
  183. echo checking for ANSI C header files
  184. echo "#include <stdlib.h>
  185. #include <string.h>
  186. main () { exit(0); strerror(0); }" > conftest.c
  187. eval $compile
  188. if test -s conftest && ./conftest 2>/dev/null; then
  189.   DEFS="$DEFS -DSTDC_HEADERS"
  190. fi
  191. rm -f conftest conftest.c
  192.  
  193. echo checking for POSIX.1 header files
  194. echo "#include <unistd.h>
  195. main () {
  196. #ifdef _POSIX_VERSION
  197. exit(0);
  198. #else
  199. exit(1);
  200. #endif
  201. }" > conftest.c
  202. eval $compile
  203. if test -s conftest && ./conftest 2>/dev/null; then
  204.   DEFS="$DEFS -DPOSIX"
  205.   PROGS="$PROGS stty"
  206.   MAN="$MAN gstty.1"
  207.   echo checking whether termios has c_line
  208.   rm -f conftest conftest.c
  209.   echo "#include <sys/types.h>
  210. #include <termios.h>
  211. main () { struct termios t; exit(0); t.c_line; }" > conftest.c
  212.   eval $compile
  213.   if test -s conftest && ./conftest 2>/dev/null; then :
  214.   else DEFS="$DEFS -DC_LINE_MISSING"
  215.   fi
  216.   rm -f conftest conftest.c
  217.   echo checking for sys/ptem.h
  218.   test -f $INCLUDEDIR/sys/ptem.h && DEFS="$DEFS -DWINSIZE_IN_PTEM"
  219.   echo checking for broken window size ioctl
  220.   echo "#include <sys/types.h>
  221. #include <termios.h>" > conftest.c
  222.   test -f $INCLUDEDIR/sys/ptem.h && echo "#include <sys/ptem.h>" >> conftest.c
  223.   echo "main() {
  224. #ifndef TIOCGWINSZ
  225. exit(0);
  226. #else
  227. struct winsize w;
  228. exit(ioctl(0, TIOCGWINSZ, &w));
  229. #endif
  230. }" >> conftest.c
  231.   eval $compile
  232.   if test -s conftest && ./conftest 2>/dev/null; then :
  233.   else DEFS="$DEFS -DGWINSZ_BROKEN"
  234.   fi
  235. fi
  236. rm -f conftest conftest.c
  237.  
  238. echo checking for BSD string and memory functions
  239. echo "#include <strings.h>
  240. main () { exit(0); rindex(0, 0); bzero(0, 0); }" > conftest.c
  241. eval $compile
  242. if test -s conftest && ./conftest 2>/dev/null; then :
  243.   else DEFS="$DEFS -DUSG"
  244. fi
  245. rm -f conftest conftest.c
  246.  
  247. echo checking whether sys/types.h defines size_t
  248. echo '#include <sys/types.h>
  249. main() { size_t x; exit(0); }' > conftest.c
  250. eval $compile
  251. if test -s conftest && ./conftest 2>/dev/null; then :
  252. else DEFS="$DEFS -Dsize_t=long"
  253. fi
  254. rm -f conftest conftest.c
  255.  
  256. echo checking whether sys/types.h defines uid_t
  257. echo '#include <sys/types.h>
  258. main() { uid_t x; exit(0); }' > conftest.c
  259. eval $compile
  260. if test -s conftest && ./conftest 2>/dev/null; then :
  261. else
  262.   uid_t=`awk '/pw_uid;/ {print $1}' $INCLUDEDIR/pwd.h`
  263.   DEFS="$DEFS -Duid_t=${uid_t} -Dgid_t=${uid_t}"
  264. fi
  265. rm -f conftest conftest.c
  266.  
  267. echo checking whether time.h has struct tm
  268. echo '#include <sys/types.h>
  269. #include <time.h>
  270. main() { struct tm *tp; exit(0); }' > conftest.c
  271. eval $compile
  272. if test -s conftest && ./conftest 2>/dev/null; then :
  273.   else DEFS="$DEFS -DTM_IN_SYS_TIME"
  274. fi
  275. rm -f conftest conftest.c
  276.  
  277. case "$LIBOBJS" in
  278. *strftime.o*)
  279.   echo checking whether struct tm has tm_zone
  280.   echo '#include <sys/types.h>' > conftest.c
  281.   case "$DEFS" in
  282.     *-DTM_IN_SYS_TIME*) echo '#include <sys/time.h>' >> conftest.c ;;
  283.     *) echo '#include <time.h>' >> conftest.c ;;
  284.   esac
  285.   echo 'main() { struct tm tm; exit(0); tm.tm_zone; }' >> conftest.c
  286.   eval $compile
  287.   if test -s conftest && ./conftest 2>/dev/null; then :
  288.   else DEFS="$DEFS -DTM_ZONE_MISSING"
  289.   fi
  290.   rm -f conftest conftest.c
  291.  
  292.   case "$DEFS" in
  293.     *-DTM_ZONE_MISSING*)
  294.     echo checking for tzname
  295.     echo '
  296. main() { extern char *tzname[2]; exit(tzname[0][0] == 1); }' > conftest.c
  297.     eval $compile
  298.     if test -s conftest && ./conftest 2>/dev/null; then :
  299.     else DEFS="$DEFS -DTZNAME_MISSING"
  300.     fi
  301.     rm -f conftest conftest.c
  302.     ;;
  303.   esac
  304.   ;;
  305. esac # strftime.o
  306.  
  307. # Check other misc. things.
  308.  
  309. echo checking for Minix
  310. if test -d /usr/include/minix; then
  311.   DEFS="$DEFS -UUSG -D_POSIX_SOURCE -D_POSIX_1_SOURCE=2 -D_MINIX"
  312. fi
  313.  
  314. echo checking for unsigned characters
  315. echo 'main() { char c = 255; exit(c < 0); }' > conftest.c
  316. eval $compile
  317. if test -s conftest && ./conftest 2>/dev/null; then
  318.   DEFS="$DEFS -DCHAR_UNSIGNED"
  319. fi
  320. rm -f conftest conftest.c
  321.  
  322. echo checking how to get alloca
  323. echo '
  324. #ifdef __GNUC__
  325. #define alloca __builtin_alloca
  326. #else
  327. #ifdef sparc
  328. #include <alloca.h>
  329. #else
  330. #ifdef _AIX
  331.  #pragma alloca
  332. #else
  333. char *alloca ();
  334. #endif
  335. #endif
  336. #endif
  337. main() { char *p = (char *) alloca(1); exit(0); }' > conftest.c
  338. eval $compile
  339. if test -s conftest && ./conftest 2>/dev/null; then :
  340. else
  341.   rm -f conftest conftest.c
  342.   echo 'char *alloca();
  343. main() { char *p = alloca(1); exit(0); }' > conftest.c
  344.   eval $compile -lPW
  345.   if test -s conftest && ./conftest 2>/dev/null; then LIBS="$LIBS -lPW"
  346.   elif test -d /usr/ucblib; then LIBS="$LIBS -L/usr/ucblib -lucb"
  347.   else ALLOCA="alloca.o"
  348.   fi
  349. fi
  350. rm -f conftest conftest.c
  351.  
  352. trap 'rm -f Makefile lib/Makefile src/Makefile man/Makefile config.status; exit 1' 1 3 15
  353.  
  354. for dir in . lib src man
  355. do
  356.   test -d $dir || mkdir $dir
  357.   echo '# Generated automatically from Makefile.in by configure.' > $dir/Makefile
  358.   sed -e "
  359. s,@srcdir@,$srcdir,
  360. s,@VPATH@,$VPATH,
  361. s,@CC@,$CC,
  362. s,@RANLIB@,$RANLIB,
  363. s,@INSTALL@,$INSTALL,
  364. s,@INSTALLDATA@,$INSTALLDATA,
  365. s,@DEFS@,$DEFS,
  366. s,@LIBS@,$LIBS,
  367. s,@LIBOBJS@,$LIBOBJS,
  368. s,@ALLOCA@,$ALLOCA,
  369. s,@PROGS@,$PROGS,
  370. s,@MAN@,$MAN,
  371. " $srcdir/$dir/Makefile.in >> $dir/Makefile
  372. done
  373.  
  374. echo "CC = $CC
  375. RANLIB = $RANLIB
  376. INSTALL = $INSTALL
  377. INSTALLDATA = $INSTALLDATA
  378. DEFS = $DEFS
  379. LIBS = $LIBS
  380. LIBOBJS = $LIBOBJS
  381. ALLOCA = $ALLOCA
  382. PROGS = $PROGS
  383. MAN = $MAN" > config.status
  384.